﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;


public partial class UserControl_ControlSetSKUForTDV : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadGridTDV();
        }
    }
    void LoadGridTDV()
    {
        dt = new ClassExecute.ClassExecute();
        try
        {
            

            DataTable db = dt.Get_Data_DataTable(str, ref error, "[k_getListTDV]", CommandType.StoredProcedure,
                new SqlParameter("@UserName",Session["user"].ToString()));

            grvTDV.DataSource = db;
            grvTDV.DataBind();

        }
        catch (Exception ex)
        {
            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
        }
    }
    protected void grvTDV_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        dt = new ClassExecute.ClassExecute();
        try
        {
            if (e.CommandName == "chon")
            {

                GridViewRow grv = ((Control)e.CommandSource).NamingContainer as GridViewRow;
                Label lblMaSo = (Label)grv.FindControl("lblsalesp_key");
                if (RadioList.SelectedValue == "0")
                {
                    Response.Redirect(webapp4U.Globals.ApplicationPath + "Pages/SetSKUForTDVFinal/Default.aspx?TDV=" + lblMaSo.Text);
                }
                else
                {
                    Response.Redirect(webapp4U.Globals.ApplicationPath + "Pages/SetRouteTDVFinal/Default.aspx?TDV=" + lblMaSo.Text);
                }
            }
        }
        catch (Exception ex)
        {

            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
        }
    }
}